import time

from config import BASE_URL
from page.page_login import LoginPage
from page.page_register import RegisterPage
from tools import DriverTools


class TestLogin(object):

    def setup_method(self):
        # 打开浏览器

        self.driver = DriverTools.get_driver()
        # 输入网址
        self.driver.get(BASE_URL + '/common/member/login')
        # 输入手机号 密码 验证码.....
        self.reg = LoginPage(self.driver)

    def teardown_method(self):
        # 关闭浏览器
        DriverTools.quit_driver()

    def test01_reg_login(self):
        self.reg.login('1380013828', 'w123456')
        result = self.reg.get_login_result()
        assert '安享智慧理财' in result
        print(result)
        self.reg.get_shot('pwd_error2.png')

    def test02_fail_login(self):
        self.reg.login('1380013828', 'w123456')
        result = self.reg.get_uesr_not()
        assert '用户不存在' in result
        print(result)
        self.reg.get_shot('pwd_error3.png')
